<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/scripts/jquery/jquery.form.js"></script>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<c:set var="UNVISIBLE" value="<%=ConstantDB.UNVISIBLE%>"></c:set>
<c:set var="VISIBLE" value="<%=ConstantDB.VISIBLE%>"></c:set>

<link rel="stylesheet" type="text/css" href="${ctx}/styles/pop.css" media="screen"/>

<div class="pop_roster_request">
	<div class="pop_roster_request_tit">
		我要留言
	</div>
	<div id="div_words_error" class="div_words_error" style="display:none"></div>
	<input id="f_words_receiver" type="hidden" name="receiver" value="${usr}"/>
	<textarea id="words_content" name="content" rows="8" cols="80"></textarea>
	<br/>
	<input type="button" value="留言" onclick="javascript:submitWordsForm()" class="btn1"/>
	<input id="f_words_visible" type="checkbox" name="visible" value="${UNVISIBLE }"/>悄悄的说
</div>
<script>
function submitWordsForm(){
	var valid = validateWordsContent();
	if(valid){
		var data = "receiver="+$("#f_words_receiver").val() + "&content="+$("#words_content").val() +"&visible="+$("#f_words_visible").val();
		$.ajax({
			url:"<c:url value='/words/words.do'/>", 
			type:"POST", 
			data:data, 
			dataType:"xml", 
			timeout:20000, 
			error:function () {
				alert("留言失败，请稍后再试试！");
			}, 
			success:function (result) {
				if($(result).find('result').text().toUpperCase().indexOf("TRUE") >= 0){
					$.fn.colorbox.close();
					alert("留言成功！");
				}else{
					alert("留言失败，请稍后再试试！");
				}
			}
		});
	}
}
</script>